//
//  DYMSDingdanInfoCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/2/6.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit
import YYText

class DYMSDingdanInfoCell: SYBaseCell {

    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 5
        v.layer.masksToBounds = true
        return v
    }()
    
    let name: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 18.autoBoldFontSize()
        
        return v
    }()
    
    let location: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 13.autoFontSize()
        
        return v
    }()
    
    let daohang: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x5D99FB)
        v.font = 12.autoFontSize()
        v.text = "地图导航 >"
        return v
    }()
    
    let shijianT: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 15.autoFontSize()
        v.text = "时间人数"
        return v
    }()
    
    let weizhiT: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 15.autoFontSize()
        v.text = "位置要求"
        return v
    }()
    let lianxiT: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 15.autoFontSize()
        v.text = "联系方式"
        return v
    }()
    
    
    let weizhi: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 15.autoFontSize()
        
        return v
    }()
    
    let shijian: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 15.autoFontSize()
        
        return v
    }()
    let lianxi: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 15.autoFontSize()
        
        return v
    }()
    
    var delete: UIButton = {
        let v = UIButton()
        v.setTitle("取消订单", for: .normal)
        v.setTitleColor(UIColor(hex: 0x666666), for: .normal)
        v.titleLabel?.font = 15.autoFontSize()
        v.layer.cornerRadius = 18.autoWidth()
        v.layer.borderWidth = 1
        v.layer.borderColor = UIColor(hex: 0x666666)?.cgColor
        return v
    }()
   

    let imgView: UIImageView = {
        let v = UIImageView()
        
        v.layer.cornerRadius = 3.autoWidth()
        return v
    }()
    
    var daohangBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    var secLineView: UIView = {
        let v = UIView()
        v.backgroundColor = Constant.bgViewColor
        return v
    }()
    
    func configure(_ model: DYMSDaiquerenModel) {
        name.text  = model.tourRestaurantVO?.name
        location.text = model.tourRestaurantVO?.address
        if model.tourRestaurantDeskVO?.isPrivate == 0 {
            weizhi.text = "大厅"
        } else {
            weizhi.text = "包间"
        }
        
        shijian.text = "\(model.dayOrTomorrow ?? "")\(model.time ?? "")，\(model.num ?? "")人"
        var chenghu:String = ""
        if model.sex == "1" {
            chenghu = "先生"
        } else {
            chenghu = "女士"
        }
        lianxi.text = "\(model.contacts ?? "")\(chenghu)   \(model.phone ?? "")"
        imgView.sy_setWithUrl(model.tourRestaurantVO?.imgUrl?.components(separatedBy: ",").first)
    }

    override func initViews() {
        
        delete.addAction {[weak self] in
            if let `self` = self {
                
            }
        }
        daohangBt.addAction {[weak self] in
            if let `self` = self {
                
            }
        }
        self.backgroundColor = .clear
        addSubview(bgView)
        bgView.addSubview(name)
        bgView.addSubview(location)
        bgView.addSubview(daohang)
        bgView.addSubview(shijian)
        bgView.addSubview(weizhi)
        bgView.addSubview(lianxi)
        bgView.addSubview(shijianT)
        bgView.addSubview(weizhiT)
        bgView.addSubview(lianxiT)
        
        bgView.addSubview(imgView)
        bgView.addSubview(secLineView)
        bgView.addSubview(lineView)
        
        bgView.addSubview(delete)
        
        
        delete.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(226.autoWidth())
            make.right.equalToSuperview().offset(-10.autoWidth())
            make.bottom.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(36.autoWidth())
            make.width.equalTo(79.autoWidth())
        }
        
        name.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(17.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(18.autoWidth())
        }
        location.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(50.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(14.autoWidth())
        }
        lineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(90.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.right.equalToSuperview().offset(-10.autoWidth())
            make.height.equalTo(0.5.autoWidth())
        }
        daohang.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(70.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(12.autoWidth())
        }
        shijian.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(106.autoWidth())
            make.left.equalToSuperview().offset(98.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        weizhi.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(136.autoWidth())
            make.left.equalToSuperview().offset(98.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        lianxi.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(166.autoWidth())
            make.left.equalToSuperview().offset(98.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        shijianT.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(106.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        weizhiT.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(136.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        lianxiT.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(166.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        imgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(16.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(60.autoWidth())
            make.width.equalTo(90.autoWidth())
        }
        secLineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(215.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.right.equalToSuperview().offset(-10.autoWidth())
            make.height.equalTo(0.5.autoWidth())
        }
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.bottom.equalToSuperview().offset(-10.autoWidth())
            make.left.equalToSuperview()
            make.right.equalToSuperview()
        }
    }
}
